<?php
class cls_data_base
{
	var $db;
	var $name;
	static function get_instance($class)
	{
		global $db_host, $db_user, $db_password, $db_name;
		$cls = "cls_data_{$class}";
		$instance = new $cls();
		$instance->name = $class;
		
		if (isset($instance->db_name)) {
			static $customer_db = null;
			if ($customer_db === null) {
				$customer_db = new cls_mysql($db_host, $db_user, $db_password, $instance->db_name);
			}
			$instance->db = $customer_db;
		} else {
			static $admin_db = null;
			if ($admin_db === null) {
				$admin_db = new cls_mysql($db_host, $db_user, $db_password, $db_name);
			}
			$instance->db = $admin_db;
		}
		return $instance;
	}
}